//存放个人中心相关接口
const express = require('express');
const router = express.Router();

const db = require('../db');


//获取用户信息
router.get('/userinfo', (req, res) => {
  db(`select * from user where id=${req.user.id}`, (err, result) => {
    if(err) throw err;
    res.send({'status': 0, message: '获取用户信息成功', data: result[0]})
  })
})

//更新用户信息


//重置密码


//更换头像
router.post('/avatar', (req, res) => {
  db(`update user set user_pic='${req.body.avatar}' where id=${req.user.id}`, (err, result) => {
    if(err) throw err;
    res.send({status: 0, message: '修改头像成功'});
  });
})

module.exports = router;